package com.cg.managesystem.service.impl;

import com.cg.managesystem.entity.LoginTicket;
import com.cg.managesystem.entity.Repair;
import com.cg.managesystem.entity.User;
import com.cg.managesystem.mapper.LoginTicketMapper;
import com.cg.managesystem.mapper.RepairMapper;
import com.cg.managesystem.mapper.UserMapper;
import com.cg.managesystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Create tao on 2019/8/13
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private LoginTicketMapper loginTicketMapper;

    @Autowired
    private RepairMapper repairMapper;

    //  查询全部用户
    @Override
    public List<User> selectAll() {
        return userMapper.selectAll();
    }

    //注册->判断用户名是否已存在
    @Override
    public User selectByUserName(String username) {
        return userMapper.selectByUserName(username);
    }

    //注册成功->数据库插入用户数据
    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    //  根据用户id查询用户信息
    @Override
    public User selectUserById(Integer uid) {
        return userMapper.selectUserById(uid);
    }

    //  根据用户id修改用户信息
    @Override
    public int updateUserById(User user) {
        return userMapper.updateUserById(user);
    }

    //  根据用户id删除用户信息
    @Override
    public int deleteUserById(Integer uid) {
        return userMapper.deleteUserById(uid);
    }

    @Override
    public int createRepairOrder(Repair repair) {
        return repairMapper.insert(repair);
    }


}
